package com.fileshare.web.dto.Vo;

import com.fileshare.web.entity.Role;
import lombok.*;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RoleVo {

    private String roleName;

    public static RoleVo fromEntity(Role role) {
        RoleVo roleVo = new RoleVo();
        BeanUtils.copyProperties(role, roleVo);
        return roleVo;
    }

    public static List<RoleVo> fromEntities(List<Role> roles) {
        return roles.stream().map(RoleVo::fromEntity).collect(Collectors.toList());
    }

}
